package com.lmx.repoDomain.tmodel;


import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;


/**
 * 系评估问卷答案表
 */
@JsonApiResource(type = "evaluateanswer")
@Table(name = "tnb_evaluate_answer")
@Entity
public class EvaluateAnswer extends BaseEntity {
	
	private String seq;//排序字段

	private String remark;// 备注

	private String content;

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private Set<CustomerServiceItem> services;// 对应照护项目
	
	private EvaluateQuestion question;// 对应的问题

	private String advices;// 照护建议
	
	private String score;// 分数

	@Column(name = "sequence")
	public String getSeq() {
		return seq;
	}

	public void setSeq(String seq) {
		this.seq = seq;
	}

	@Column(name = "score")
	public String getScore() {
		return score;
	}

	public void setScore(String score) {
		this.score = score;
	}

	@Column(name = "advices")
	public String getAdvices() {
		return advices;
	}

	public void setAdvices(String advices) {
		this.advices = advices;
	}

	@JsonApiToOne 
    @JsonApiIncludeByDefault     //huibati
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @Fetch(FetchMode.JOIN)
	@JoinColumn(name = "question_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public EvaluateQuestion getQuestion() {
		return question;
	}

	public void setQuestion(EvaluateQuestion question) {
		this.question = question;
	}
	
	@JsonApiToMany
	@JsonApiIncludeByDefault
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinTable(name = "tnb_evaluateanswer_serviceitem", joinColumns = {
			@JoinColumn(name = "evaluateanswer_id", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) }, inverseJoinColumns = {
					@JoinColumn(name = "serviceitem_id", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) })
	@Fetch(FetchMode.JOIN)
	public Set<CustomerServiceItem> getServices() {
		return services;
	}

	public void setServices(Set<CustomerServiceItem> services) {
		this.services = services;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "content")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}


	public EvaluateAnswer() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
